import instance from '@/util/http'
import { type myUserData, type restPwInfo, type userDataInfo, type userS } from '@/page/types/admin/user'
import { type roleInfo } from '@/page/types/admin/role'
import { type menuDataInfo, menuEditInfo } from '@/page/types/admin/menu'
import { type RoleMenuInfo } from '@/page/types/admin/roleMenu'
import { type companyInfo, type companyPicture, type companySeachInfo } from '@/page/types/admin/company'
import { type deptInfo, type deptSeachInfo } from '@/page/types/admin/dept'
import { type JobInfo, type jobSInfo } from '@/page/types/admin/job'
import { type loginDataValue } from '@/page/types/admin/login'
/**
 * 登录
 * @param data
 */
export const login = (data: loginDataValue) => instance.post('/admin/login', data)
/**
 *
 * @param token 推出登录
 * @returns
 */
export const logOffs = () => instance.put('/admin/logOff')

/**
 * 获取菜单
 */
export const getMenu = async () => instance.get('/admin/menu/menu')

/**
 * 获取菜单
 */
export const menuList = (data: menuDataInfo) => instance.post('/admin/menu/list', data)

/**
 * 获取用户信息
 */
export const getUserInfo = async () => instance.get('/admin/user/detail')
/**
 * 更新用户信息
 */
export const updateUser = async (data: myUserData) => instance.put('/admin/user/update', data)
/**
 * 更新密码
 * @param data
 */

export const updatePw = async (data: restPwInfo) => instance.put('/admin/user/updatePw', data)
/**
 * 获取用户信息分页
 * @param data
 */
export const pageUser = async (data: userS) => instance.post('/admin/user/page', data)
/**
 * 保存用户信息
 */
export const saveUser = async (data: userDataInfo) => instance.post('/admin/user/save', data)
/**
 * 获取用户详情
 * @param id
 */
export const detailUser = async (id: string | undefined) => instance.get('/admin/user/detail', { id: id })
/**
 * 编辑用户信息
 * @param data
 */
export const editUser = async (data: userDataInfo) => instance.put('/admin/user/update', data)
/**
 * 删除用户信息
 * @param id
 */
export const deleteUser = async (id: string | undefined) => instance.delete('/admin/user/delete/' + id)
/**
 *  用户列表
 * @param companyId
 */
export const userSelect = async (companyId: string | null) => instance.get('/admin/ucdj/userSelect', { params: companyId })

/**
 * 获取角色信息
 * @returns
 */

export const pageRole = async (data: roleInfo) => instance.post('/admin/role/page', data)
/**
 *  保存角色
 * @param data
 * @returns
 */
export const addRole = async (data: roleInfo) => instance.post('/admin/role/save', data)
/**
 * 获取没有绑定的角色列表
 * @returns
 */

export const bindRoleList = async () => instance.get('/admin/user/role/bindRole')

/**
 * 更新角色信息
 * @param data
 * @returns
 */
export const updateRole = async (data: roleInfo) => instance.put('/admin/role/update', data)

/**
 * 删除角色
 * @param id
 * @returns
 */
export const deleteRole = async (id: string | null) => instance.delete('/admin/role/delete/' + id)
/**
 *  得到角色详情
 * @param id
 * @returns
 */
export const getRoleDetail = async (id: string | null) => instance.get('/admin/role/detail', { id: id })
/**
 * 添加菜单
 * @param data
 */
export const addMenu = async (data: menuEditInfo) => instance.post('/admin/menu/add', data)

/**
 * 菜单下拉框
 * @param name
 * @param type
 */
export const selectMenu = async (name: string, type: string) => instance.post('/admin/menu/select', { name: name, type: type })

/**
 * 删除菜单
 * @param id
 */
export const deleteMenu = async (id: string) => instance.delete('/admin/menu/delete/' + id)
/**
 * 获取菜单详情
 * @param id
 */
export const detailMenu = (id: string) => instance.get('/admin/menu/detail/' + id)
/**
 * 更新菜单
 * @param data
 */
export const updateMenu = async (data: menuEditInfo) => instance.put('/admin/menu/update', data)
/**
 * 获取树形菜单 菜单
 * @param name
 * @param type
 */
export const treeSelect = async (name: string, type: string, roleId: string | null) => instance.get('/admin/menu/treeSelect', { name: name, type: type, roleId: roleId })
/**
 * 保存角色菜单
 * @param data
 */
export const saveRoleMenu = async (data: RoleMenuInfo) => instance.post('/admin/role/menu/add', data)
/**
 * 获取公司page
 * @param data
 */

export const companyPage = async (data: companySeachInfo) => instance.post('/admin/company/page', data)
/**
 * 保存公司
 * @param data
 */

export const addCompany = async (data: companyInfo) => instance.post('/admin/company/save', data)
/**
 * 更新公司
 * @param data
 */

export const editCompany = async (data: companyInfo) => instance.put('/admin/company/update', data)
/**
 * 删除公司
 * @param id
 */
export const delCompany = async (id: string) => instance.delete('/admin/company/delete/' + id)
/**
 * 公司详情
 * @param id
 */
export const companyDetail = async (id: string) => instance.get('/admin/company/detail', { id: id })
/**
 *公司添加图片
 * @param data
 */
export const addCompanyPicture = async (data: companyPicture) => instance.post('/admin/company/addPicture', data)
/**
 * 得到公司图片
 * @param companyId
 */
export const getCompanyPricture = async (companyId: string) => instance.get('/admin/company/getPicture', { companyId: companyId })

/**
 * 公司下拉
 * @param name
 */
export const selectCompany = async (name: string | null) => instance.get('/admin/ucdj/getCompanyList', { pid: name })
/**
 * 获取部门分页
 * @param data
 */
export const deptPage = async (data: deptSeachInfo) => instance.post('/admin/dept/tree', data)

/**
 * 获取部门下拉框
 * @param pid
 */
export const selectDeptBox = async (data: any) => instance.post('/admin/company/dept/select/dept', data)
/**
 * 保存部门
 * @param data
 */
export const saveDept = async (data: deptInfo) => instance.post('/admin/dept/save', data)
/**
 * 更新部门
 * @param data
 */
export const updateDept = async (data: deptInfo) => instance.put('/admin/dept/update', data)
/**
 * 部门详细信息
 * @param id
 */
export const detailDept = async (id: string) => instance.get('/admin/dept/detail/' + id)
/**
 * 删除部门
 * @param id
 */
export const deleteDept = async (id: string) => instance.delete('/admin/dept/delete/' + id)
/**
 * 岗位分页列表
 * @param data
 */
export const jobPage = async (data: jobSInfo) => instance.post('/admin/job/page', data)
/**
 * 保存岗位
 * @param data
 */
export const saveJob = async (data: JobInfo) => instance.post('/admin/job/save', data)
/**
 * 更新岗位
 * @param data
 */
export const updateJob = async (data: JobInfo) => instance.put('/admin/job/update', data)
/**
 * 岗位详情
 * @param id
 */
export const detailJob = async (id: string) => instance.get('/admin/job/detail', { id: id })
/**
 * 删除岗位
 * @param id
 */
export const deleteJob = async (id: string) => instance.delete('/admin/job/delete/' + id)
/**
 * 获取岗位下拉框
 * @param name
 * @param deptId
 */
export const getJobSelect = async (name: string | null, deptId: string) => instance.get('/admin/ucdj/select/job', { name: name, deptId: deptId })
/**
 * 获取枚举list
 */
export const getEnumList = (name: string) => instance.get('/admin/enum/getList/' + name)
